package main

import (
	"go-admin-template/config"
	"go-admin-template/model"
	"go-admin-template/router"
	"net/http"
	"time"
)

func main() {

	// 初始化数据库连接
	Db := model.Init()
	// 连接关闭
	defer Db.Close()

	// 初始化路由
	engine := router.Router()

	server := &http.Server{
		Addr:           ":" + config.Info.Server.Port,
		Handler:        engine,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	if err := server.ListenAndServe(); err != nil {
		panic("启动服务错误")
	}
}
